/*
 * Created by SharpDevelop.
 * User: MyWife
 * Date: 1/1/2003
 * Time: 12:07 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Drawing;
using System.Windows.Forms;
using System.IO;
using IconPack;
using popLib;
using System.Collections;
using System.Collections.Generic;

namespace FileAssociateManager
{
	/// <summary>
	/// Description of IconViewer.
	/// </summary>
	public partial class IconViewer : Form
	{
		public IconViewer()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			btn_canel.Click += delegate { this.Hide(); };
		}
		
		public void ViewIconFromFile( string file ){
			flowLayoutPanel1.Controls.Clear();
			isOK = false;
			if( !File.Exists(file) ) return;			
			List<Icon> icons = IconHelper.ExtractAllIcons( file );
			
			for( int i = 0; i< icons.Count; i++ ){
				
				PictureBox img = new PictureBox();
				img.Image = icons[i].ToBitmap();
				img.Size = icons[i].Size;
				img.Cursor = Cursors.Hand;
				img.Click += delegate { 
					filename = file + "," + (i-1);
					isOK = true;
					this.Hide();					
				};
				flowLayoutPanel1.Controls.Add( img );
			}
			this.ShowDialog();
		}
		
		string filename;
		public string Filename{
			get{ return filename; }
		}
		
		bool isOK = false;
		public bool IsOK{
			get{ return isOK;}
		}
		
	}
}
